import { getFormattedDate } from '../../utils/date';

Component({

  /**
   * 组件的属性列表
   */
  properties: {

  },

  data: {
    date: '',
    city: 'shenzhen',
    weather: {
      air_quality: "-",
      date: "2025年03月01日　星期六　乙巳年二月初二 ",
      humidity: "-",
      pm: "-",
      sunrise: "-",
      sunset: "-",
      tempera_today: "-",
      temperature_now: "-",
      ultraviolet_rays: "无",
      wind_direction: "-",
    }
  },

  lifetimes: {
    ready() {
      this.setData({
        date: getFormattedDate(),
      })
      this.getWeather()
    }
  },

  /**
   * 组件的方法列表
   */
  methods: {
    getWeather() {
      const that = this;
      wx.request({
        url: 'https://weather.hanxiaoxin.cn/weather.json',
        method: 'GET',
        header: {
          'content-type': 'application/json'
        },
        success: (res: any) => {
          that.setData({
            weather: res.data
          })
        }
      })
    }
  }
})